<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>openGauss Blog  | 从Oracle到openGauss：字典表DBATABLES到tables对应</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">

    
    <link rel="shortcut icon" href="https://xzx666.gitee.io/lookeng/img/favicon.ico" type="image/x-icon" />
    <link rel="apple-touch-icon" href="https://xzx666.gitee.io/lookeng/img/apple-touch-icon.png" />

    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script>
    
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/commen.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/blog.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/mobile.css?t=1607593672000" />
    <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/pagination.css?t=1607593672000">
    
    <script>
      var _hmt = _hmt || [];
      (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?34e9f585f29581007941aa1698181871";
        var s = document.getElementsByTagName("script")[0]; 
        s.parentNode.insertBefore(hm, s);
      })();
    </script>
</head>
<body>
  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src='//unpkg.com/valine/dist/Valine.min.js'></script>






<div class="container">
    <div class="columns blog-detail">
        <div class="post_detail">
            <div class="is-child box">
                <div class="breadCrumb"><a href="\zh\">博客/</a></div>
                <div class="blog-detail-header">
                    <h1>从Oracle到openGauss：字典表DBATABLES到tables对应</h1>
                    <div class="blog-detail-prop">
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-date.png">
                        <span class="article_right_date">2020-11-19</span>
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-author.png">
                        <span class="article_right_author">盖国强</span>
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-view.png">
                        <span id="/zh/post/gaiguoqiang/%E4%BB%8Eoracle%E5%88%B0opengauss%E5%AD%97%E5%85%B8%E8%A1%A8dbatables%E5%88%B0tables%E5%AF%B9%E5%BA%94/" class="leancloud_visitors" data-flag-title="从Oracle到openGauss：字典表DBATABLES到tables对应">
                            <i class="leancloud-visitors-count"></i>                     
                        </span>
                    </div>
                    <div class="blog-detail-tags">
                        <img src="https://xzx666.gitee.io/lookeng/img/icon-tag.png">
                        
                        <a href="https://xzx666.gitee.io/lookeng/zh/tags/%E4%BB%8Eoracle%E5%88%B0opengauss%E5%AD%97%E5%85%B8%E8%A1%A8dbatables%E5%88%B0tables%E5%AF%B9%E5%BA%94">从Oracle到openGauss：字典表DBATABLES到tables对应</a>
                        
                    </div>
                </div>
                <div class="content blog-content">
                    

<h1 id="从oracle到opengauss-字典表dbatables到tables对应-a-name-zh-cn-topic-0293240557-a">从Oracle到openGauss：字典表DBATABLES到tables对应<a name="ZH-CN_TOPIC_0293240557"></a></h1>

<p>从Oracle数据库向其他数据库过度时，很多朋友会自然而然的寻找属性都过度方式，例如字典表。</p>

<p>有人问，类似DBA_TABLES，DBA_TAB_COLUMNS的字典，在openGauss中是否存在呢？</p>

<pre><code>SELECT OWNER, TABLE_NAME FROM DBA_TABLES;

SELECT COLUMN_NAME, 
       DATA_TYPE, 
       DATA_LENGTH,
       COLUMN_ID, 
       DATA_PRECISION, 
       DATA_SCALE 
FROM DBA_TAB_COLUMNS
</code></pre>

<p>当然会存在对应关系：</p>

<p>ALL_TABLES =&gt; information_schema.tables</p>

<pre><code>postgres=&gt; \d information_schema.tables
                       View &quot;information_schema.tables&quot;
            Column            |               Type                | Modifiers 
------------------------------+-----------------------------------+-----------
 table_catalog                | information_schema.sql_identifier | 
 table_schema                 | information_schema.sql_identifier | 
 table_name                   | information_schema.sql_identifier | 
 table_type                   | information_schema.character_data | 
 self_referencing_column_name | information_schema.sql_identifier | 
 reference_generation         | information_schema.character_data | 
 user_defined_type_catalog    | information_schema.sql_identifier | 
 user_defined_type_schema     | information_schema.sql_identifier | 
 user_defined_type_name       | information_schema.sql_identifier | 
 is_insertable_into           | information_schema.yes_or_no      | 
 is_typed                     | information_schema.yes_or_no      | 
 commit_action                | information_schema.character_data |  
</code></pre>

<p><a href="http://www.postgresql.org/docs/current/static/infoschema-tables.html">http://www.postgresql.org/docs/current/static/infoschema-tables.html</a></p>

<p>ALL_TAB_COLUMNS =&gt; information_schema.columns</p>

<pre><code>postgres=&gt; \d information_schema.columns
                     View &quot;information_schema.columns&quot;
          Column          |                Type                | Modifiers 
--------------------------+------------------------------------+-----------
 table_catalog            | information_schema.sql_identifier  | 
 table_schema             | information_schema.sql_identifier  | 
 table_name               | information_schema.sql_identifier  | 
 column_name              | information_schema.sql_identifier  | 
 ordinal_position         | information_schema.cardinal_number | 
 column_default           | information_schema.character_data  | 
 is_nullable              | information_schema.yes_or_no       | 
 data_type                | information_schema.character_data  | 
 character_maximum_length | information_schema.cardinal_number | 
 character_octet_length   | information_schema.cardinal_number | 
 numeric_precision        | information_schema.cardinal_number | 
 numeric_precision_radix  | information_schema.cardinal_number | 
 numeric_scale            | information_schema.cardinal_number | 
 datetime_precision       | information_schema.cardinal_number | 
 interval_type            | information_schema.character_data  | 
 interval_precision       | information_schema.cardinal_number | 
 character_set_catalog    | information_schema.sql_identifier  | 
 character_set_schema     | information_schema.sql_identifier  | 
 character_set_name       | information_schema.sql_identifier  | 
 collation_catalog        | information_schema.sql_identifier  | 
 collation_schema         | information_schema.sql_identifier  | 
 collation_name           | information_schema.sql_identifier  | 
 domain_catalog           | information_schema.sql_identifier  | 
 domain_schema            | information_schema.sql_identifier  | 
 domain_name              | information_schema.sql_identifier  | 
 udt_catalog              | information_schema.sql_identifier  | 
 udt_schema               | information_schema.sql_identifier  | 
 udt_name                 | information_schema.sql_identifier  | 
 scope_catalog            | information_schema.sql_identifier  | 
 scope_schema             | information_schema.sql_identifier  | 
 scope_name               | information_schema.sql_identifier  | 
 maximum_cardinality      | information_schema.cardinal_number | 
 dtd_identifier           | information_schema.sql_identifier  | 
 is_self_referencing      | information_schema.yes_or_no       | 
 is_identity              | information_schema.yes_or_no       | 
 identity_generation      | information_schema.character_data  | 
 identity_start           | information_schema.character_data  | 
 identity_increment       | information_schema.character_data  | 
 identity_maximum         | information_schema.character_data  | 
 identity_minimum         | information_schema.character_data  | 
 identity_cycle           | information_schema.yes_or_no       | 
 is_generated             | information_schema.character_data  | 
 generation_expression    | information_schema.character_data  | 
 is_updatable             | information_schema.yes_or_no       | 
</code></pre>

<p><a href="http://www.postgresql.org/docs/current/static/infoschema-columns.html">http://www.postgresql.org/docs/current/static/infoschema-columns.html</a></p>

<p>供参考。</p>

                </div>
            </div>
            <div class="box" style="margin-top:15px;">
                <div style="font-size:14px;color:gray"><strong>【免责声明】</strong>本文仅代表作者本人观点，与本网站无关。本网站对文中陈述、观点判断保持中立，不对所包含内容的准确性、可靠性或完整性提供任何明示或暗示的保证。本文仅供读者参考，由此产生的所有法律责任均由读者本人承担。</div>
            </div>
            <div class="post-comment">
                
                  
  <link rel="stylesheet" href="https://xzx666.gitee.io/lookeng/css/custom.css" />
  <div id="vcomments" lang="zh-cn" mess="说点什么吧..."></div>

  <script type="text/javascript">
    const placeholder = document.getElementById("vcomments").getAttribute("mess"),
          lang = document.getElementById("vcomments").getAttribute("lang");
    const  langs = lang == "zh-cn" ? "zh-cn" : "en";
    new Valine({
        el: '#vcomments' ,
        appId: '6wfgavgIRqmpC3hjHqQVtFWF-gzGzoHsz',
        appKey: 'QRqrBDBB0p0YhrGe9IJ169ip',
        avatar:'mm', 
        placeholder: placeholder,
        visitor: true,
		    meta: ['nick','mail','link'],
        lang: langs
    });
  </script>
            </div>
        </div>
    </div>
</div>
<script>
    $(function (){
        var query = new AV.Query('Counter');
        query.equalTo('url', decodeURIComponent('\/zh\/post\/gaiguoqiang\/%E4%BB%8Eoracle%E5%88%B0opengauss%E5%AD%97%E5%85%B8%E8%A1%A8dbatables%E5%88%B0tables%E5%AF%B9%E5%BA%94\/'));
        query.find().then(function (data) {
            if(data.length && (data[0].attributes.author === 'openGauss')){
                var counter = AV.Object.createWithoutData('Counter', data[0].id);
                counter.set('author', '盖国强');
                counter.save();
            }
        })
    })
</script>







<input id="iframeUrl" type="text" style="display: none;" value=https://xzx666.gitee.io/>




<script defer src="https://xzx666.gitee.io/lookengjs/all.js"></script>
<script src="https://xzx666.gitee.io/lookengjs/flexible.js"></script>
<script>
  const hash = window.location.search,
        pageurl = window.location.href;
  var langss = document.querySelector("html").lang === "zh-cn" ? "zh" : "en";
  console.log("hash:",hash,"pageurl:",pageurl,"ttr",pageurl.split(langss + "/")[1])

  if(!document.getElementById("vcomments")) {
    new Valine({
        appId: '6wfgavgIRqmpC3hjHqQVtFWF-gzGzoHsz',
        appKey: 'QRqrBDBB0p0YhrGe9IJ169ip',
        avatar:'mm',
        visitor: true,
		    meta: ['nick','mail','link']
    });
  }
 
  
    


    const url = document.getElementById("iframeUrl").value;

    function observe (el, options, callback) {
      var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver
      var observer = new MutationObserver(callback)
      observer.observe(el, options)
    }

    var options = {
        childList: true,
        subtree: true,
        characterData: true
      }
    observe(document.body, options, (records, instance) => {
    const height = document.body.scrollHeight;
    parent.postMessage(height,url);
    })
    if(pageurl.split(langss + "/")[1]) parent.postMessage(pageurl.split(langss + "/")[1],url);
    

    if(document.querySelector("#notFound")) parent.postMessage("我404了",url);

</script>
</body>
</html>
